package com.mike.uaa.server.authentication;

import java.util.Objects;

/**
 * @author z
 */
public class AuthorizationGrantType {


    public static final AuthorizationGrantType PASSWORD = new AuthorizationGrantType("password");
    public static final AuthorizationGrantType CODE = new AuthorizationGrantType("code");


    private static final AuthorizationGrantType DEFAULT = new AuthorizationGrantType("default");

    private final String value;

    public AuthorizationGrantType(String value) {
        this.value = value;
    }

    public boolean matches(String code) {
        return Objects.equals(this.value, code);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AuthorizationGrantType that = (AuthorizationGrantType) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(value);
    }
}
